package com.kmdd.xtds.room

import android.content.Context
import androidx.room.*

@Database(entities = [BloodPressure::class,BloodSugar::class], version = 1, exportSchema = false)
abstract class BloodPressureDatabase : RoomDatabase() {
    abstract fun bloodPressureDao(): BloodPressureDao?

    abstract fun bloodSugarDao(): BloodSugarDao?


    companion object {
        private var instance: BloodPressureDatabase? = null
        private val sLock = Any()

        fun getInstance(context: Context): BloodPressureDatabase? {
            synchronized(sLock) {
                if (instance == null) {
                    instance = Room.databaseBuilder(
                        context.applicationContext,
                        BloodPressureDatabase::class.java,
                        "blood.db"
                    ).apply {
                        fallbackToDestructiveMigration()
                    }
                        .build()
                }
                return instance
            }
        }


    }
}